package com.damai.push;

import java.io.IOException;

import org.citywithincity.jobqueue.JobException;
import org.citywithincity.jobqueue.JobHandler;

import com.damai.annotation.Model;
import com.damai.push.JPushModel.PushBuilder;

public class PushJobHandler implements JobHandler<PushBuilder> {
	
	@Model(bean="push")
	private JPushModel model;
	@Override
	public void onAsyncJob(PushBuilder job) throws JobException {
		int count = 2;
		while(count>0){
			try {
				model.send(job);
				break;
			} catch (IOException e) {
				--count;
				if(count<=0){
					throw new JobException();
				}
			}
		}
		
	}

	


}
